/* This is a small demo of the high-performance GUIX graphics framework. */

#include <stdio.h>
#include "tx_api.h"
#include "gx_api.h"
#include "gx_validation_utility.h"

TEST_PARAM test_parameter = {
    "guix_line_chart", /* Test name */
    0, 0, 639, 479  /* Define the coordinates of the capture area.
                         In this test, we only need to capture the pixelmap
                         drawing area.  */
};

static VOID      control_thread_entry(ULONG);
int main(int argc, char ** argv)
{
    /* Parse the command line argument. */
    gx_validation_setup(argc, argv);

    /* Start ThreadX system */
    tx_kernel_enter(); 
    return(0);
}

VOID tx_application_define(void *first_unused_memory)
{

    /* Create a dedicated thread to perform various operations
       on the line drawing example. These operations simulate 
       user input. */
    gx_validation_control_thread_create(control_thread_entry);

    /* Termiante the test if it runs for more than 100 ticks */
    /* This function is not implemented yet. */
    gx_validation_watchdog_create(100);

    /* Call the actual line example routine. */
    gx_validation_application_define(first_unused_memory);

}

#ifdef win32_graphics_driver_setup_565rgb
#undef win32_graphics_driver_setup_565rgb  
#endif
#define win32_graphics_driver_setup_565rgb  gx_validation_graphics_driver_setup_565rgb

#ifdef WIN32
#undef WIN32
#endif

#include "gx_validation_wrapper.h"
#include "demo_guix_chart.c"

char test_comment[255];

/* This thread simulates user input.  Its priority is lower
   than the GUIX thread, so that GUIX finishes an operation 
   before this thread is able to issue the next command. */
static VOID control_thread_entry(ULONG input)
{
int  frame_id = 1;
int  index;
int  base_val;
GX_LINE_CHART *chart;

    chart = &pressure_trend_frame.pressure_trend_frame_line_chart;
 
    gx_system_timer_stop((GX_WIDGET *)&pressure_trend_frame, ID_CHART_TIMER);
    
    num_data_vals = MAX_DATA_COUNT;

    base_val = DATA_MAX_VAL / 3;
    for (index = 0; index < num_data_vals; index++)
    {
        chart_data[index] = base_val + index;
    }
    gx_line_chart_update(chart, chart_data, num_data_vals);
 
    gx_validation_set_frame_id(frame_id++);
    gx_validation_set_frame_comment("test line chart draw");
    gx_validation_screen_refresh();

    chart->gx_line_chart_info.gx_line_chart_max_data_count = 0;
    gx_validation_set_frame_id(frame_id++);
    gx_validation_set_frame_comment("set max_data_count = 0");
    gx_validation_screen_refresh();

    chart->gx_line_chart_info.gx_line_chart_max_val = chart->gx_line_chart_info.gx_line_chart_min_val;
    gx_validation_set_frame_id(frame_id++);
    gx_validation_set_frame_comment("set chart_max_val = chart_min_val");
    gx_validation_screen_refresh();

    chart->gx_line_chart_info.gx_line_chart_data = GX_NULL;
    gx_validation_set_frame_id(frame_id++);
    gx_validation_set_frame_comment("set chart_data = GX_NULL");
    gx_validation_screen_refresh();


    /* Signal the end of the test case.  Verify the output. */
    gx_validation_end();

    exit(0);
}
